﻿using HR60_PanelSoft.Model;
using HR60_PanelSoft.Tools;
using HR60_PanelSoft.NetWork.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HR60_PanelSoft.NetWork.Sender
{
    class Sender_0115:BaseSender
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="panelNo"></param>
        /// <param name="type">类型：1空调、2地暖、3新风、4背景音乐</param>
        /// <param name="page"></param>
        public Sender_0115(byte panelNo, byte type, ExPanelPage page)
        {

            byte [] data = new byte[16];

            int i = 0;
            List<Device> sublist = page.getMappingSubExDevice();
            if (CollectionUtils.isBlank(sublist))
                return;
            Device parent = Device.findParent(sublist[0]);
            List<Device> subAllList = parent.childDevices;

            foreach(Device sub in  sublist){
                if (i > 15)
                    break;

                data[i++] = (byte)(subAllList.IndexOf(sub)+1);

            }


            this.package = Package.getPackage(0x01, 0x15, panelNo, type, data);


        }
    }
}
